Skip to content

Upgrade Rails from 7.2 to 8.0#6955

Merged
compwron merged 26 commits into
rubyforgood:mainfrom
hexdevs:upgrade-to-rails-8.0
May 27, 2026
Merged

Upgrade Rails from 7.2 to 8.0#6955
compwron merged 26 commits into
rubyforgood:mainfrom
hexdevs:upgrade-to-rails-8.0

Conversation

@stefannibrasil
Copy link
Copy Markdown
Contributor

@stefannibrasil stefannibrasil commented May 20, 2026

What github issue is this PR for, if any?

Closes #6925

What changed, and why?

Rails 8.0 was released in late 2024 and brings Solid Queue / Solid Cache / Solid Cable as defaults, Propshaft, Kamal 2, Authentication generator, and a number of framework deprecations.

Most notable changes:

  • It's not possible to use only and except for non-RESTful routes: c64228a
  • I removed comments and configs from previous upgrades, and updated config/environments with the generated files as much as possible
  • I couldn't find out exactly where this changed in the release notes for this Rails version but I imagine it's a good change since it shows the new 404 page instead of raising a server error: c5af932
  • The new defaults from config/initializers/new_framework_defaults_8_0.rb look okay to be enabled altogether but if you prefer to enable them individually, let me know.
  • The 406 and 422 error pages have a new generated UI:
Screenshot 2026-05-15 at 12 11 29 PM Screenshot 2026-05-15 at 12 07 35 PM

How is this tested? (please write rspec and jest tests!) 💖💪

  • tested the app locally
  • running tests
  • CI is passing

Followups

  • Once Rails 8 is up and running, we can later update the config.load_defaults to 8.0. It should fix this deprecation warning: "DEPRECATION WARNING: to_time will always preserve the full timezone rather than offset of the receiver in Rails 8.1. To opt in to the new behavior, set config.active_support.to_time_preserves_timezone = :zone. (called from <top (required)> at /home/runner/work/casa/casa/config/environment.rb:5)"
  • It's possible to upgrade from Sprockets to Propshaft: https://github.com/rails/propshaft/blob/main/UPGRADING.md
  • upgrade Rails from 8.0 to 8.1 (should be smooth, no breaking changes)

Questions

Is it possible to test this on staging/QA first? Please try this out locally and let me know if you run into any issues.

@github-actions github-actions Bot added 🧪 Tests Tests dependencies Touches dependency files ruby Touches Ruby code labels May 20, 2026
@compwron
Copy link
Copy Markdown
Collaborator

cooollll :)

@stefannibrasil stefannibrasil force-pushed the upgrade-to-rails-8.0 branch from 4d12204 to c5af932 Compare May 20, 2026 21:26
@stefannibrasil stefannibrasil force-pushed the upgrade-to-rails-8.0 branch from 5eb704c to d37e734 Compare May 20, 2026 21:39
Comment thread bin/dev Outdated

foreman start -f Procfile.dev "$@"
#!/usr/bin/env ruby
exec "./bin/rails", "server", *ARGV
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested things locally and this seems fine. Could someone try it out and see if it's best to keep the previous changes?

# If set to `:zone`, `to_time` methods will use the timezone of their receivers.
# If set to `:offset`, `to_time` methods will use the UTC offset.
# If `false`, `to_time` methods will convert to the local system UTC offset instead.
#++
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new defaults look okay to be enabled altogether...

Comment thread config/routes.rb
end
end
resources :reimbursements, only: %i[index change_complete_status], concerns: %i[with_datatable] do
resources :reimbursements, only: %i[index], concerns: %i[with_datatable] do
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See rails/rails#51464

I tested the removed routes and they work as expected.

@@ -1,6 +1,4 @@
require "rails_helper"
# require "contact_type_group"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was left here from the previous upgrade, but it's not necessary anymore.

it "raises RoutingError if no step in url" do
expect { patch "/case_contacts/#{case_contact.id}/form", params: {case_contact: attributes} }
.to raise_error(ActionController::RoutingError)
it "responds with 404 if no step in url" do
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find out exactly where this changed in the release notes for this Rails version but I imagine it's a good change since it shows the new 404 page instead of raising a server error.

@stefannibrasil
Copy link
Copy Markdown
Contributor Author

@compwron could you test this branch locally and in staging as well? I want to make sure I am not introducing anything that I couldn't test locally. Thanks!

@compwron
Copy link
Copy Markdown
Collaborator

very cool, will do

@compwron
Copy link
Copy Markdown
Collaborator

  1. annotate gem silently downgraded 3.2.0 → 2.6.5
  • annotate (3.2.0)
  •  activerecord (>= 3.2, < 8.0)
    
  • annotate (2.6.5)
  •  activerecord (>= 2.3.0)
    

annotate is unmaintained and pinned < 8.0, so bundler walked back ~7 years to find a Rails-8-compatible
version. That's a real regression — 2.6.5 predates many features and could produce different schema
annotations. Switch to the maintained fork annotaterb, or pin/remove it deliberately. Don't merge with
this downgrade.

@stefannibrasil
Copy link
Copy Markdown
Contributor Author

stefannibrasil commented May 25, 2026

Switch to the maintained fork annotaterb, or pin/remove it deliberately. Don't merge with this downgrade.

Ah, thanks for catching that! Since it's not compatible and it's a dev dependency that is not critical, I would propose removing annonate in a separate Pull Request, and create a follow up issue to migrate to annotaterb to be done after this Rails upgrade is done.

@stefannibrasil
Copy link
Copy Markdown
Contributor Author

stefannibrasil commented May 25, 2026

Actually, I created #6962 to replace annotate with annotaterb ahead of this upgrade. Once that is merged, I will update this PR.

@github-actions github-actions Bot added the db Touches database schema or migrations label May 25, 2026
@stefannibrasil
Copy link
Copy Markdown
Contributor Author

stefannibrasil commented May 25, 2026

Followups:

  • update config/application.rb: config.load_defaults 8.0
  • migrate Sprockets to propshaft
  • upgrade Rails from 8.0 to 8.1 (should be smooth, no breaking changes)

@stefannibrasil
Copy link
Copy Markdown
Contributor Author

@compwron I handled annotate separately in #6962. That one can be merged first, then I will update this one. From there, if you could test locally again, and on QA/staging before merging this, that would be awesome 🙌🏼 I am happy to test in QA/staging as well, if that's an option. Thank you!!

@compwron
Copy link
Copy Markdown
Collaborator

Very cool :) #6962 is now merged!

@stefannibrasil
Copy link
Copy Markdown
Contributor Author

thanks @compwron this is now ready for local/staging QA 🎉

Comment thread bin/dev
gem install foreman
fi

foreman start -f Procfile.dev "$@"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the procfile for local and remote deployment, add this back? https://github.com/rubyforgood/casa/blob/main/Procfile

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! I reverted it back in 32121eb

Comment thread bin/rubocop Outdated
# explicit rubocop config increases performance slightly while avoiding config confusion.
ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))

load Gem.bin_path("rubocop", "rubocop")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This codebase uses standardrb not rubocop

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼 removed the file in 736b89f

compwron
compwron previously approved these changes May 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Upgrades the CASA Rails application from Rails 7.2 to Rails 8.0, incorporating the Rails 8-generated configuration defaults and aligning routes, error pages, and tests with updated framework behavior.

Changes:

  • Bump Rails to ~> 8.0 and update Gemfile.lock / db/schema.rb accordingly.
  • Refresh Rails environment config (dev/test/prod), Puma config, and add new_framework_defaults_8_0.rb.
  • Update public error pages and adjust routing/tests to reflect Rails 8 exception/rendering behavior.

Reviewed changes

Copilot reviewed 16 out of 22 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
spec/requests/case_contacts/form_spec.rb Updates request spec expectation from raising to 404 response.
spec/models/contact_type_group_spec.rb Removes explicit model require (leans on Rails autoloading).
public/icon.svg Updates default icon SVG shape/size.
public/422.html Replaces legacy 422 page with Rails 8 generated page.
public/406-unsupported-browser.html Replaces legacy 406 page with Rails 8 generated page.
public/400.html Adds Rails 8 generated 400 error page.
Gemfile.lock Locks Rails 8.0.x and associated dependency updates.
Gemfile Bumps Rails requirement to ~> 8.0.
doc/DOCKER.md Removes webpack dev server guidance.
db/schema.rb Updates schema version to 8.0 and adjusts extension name output.
config/routes.rb Adjusts only/except usage to comply with Rails 8 routing constraints.
config/puma.rb Adds optional Solid Queue Puma plugin hook and refreshes comments.
config/initializers/new_framework_defaults_8_0.rb Adds Rails 8 framework defaults initializer and enables settings.
config/initializers/filter_parameter_logging.rb Expands filtered parameter list (e.g., email/card fields).
config/initializers/assets.rb Removes older precompile comment block.
config/environments/test.rb Updates test environment settings, including exception rendering behavior.
config/environments/production.rb Refreshes production config to closer match Rails 8 generated defaults.
config/environments/development.rb Refreshes development config to closer match Rails 8 generated defaults.
bin/setup Adjusts command runner behavior in setup script.
bin/rubocop Adds a rubocop binstub wrapper.
bin/dev Changes dev launcher behavior (now only starts Rails server).

Comment thread config/environments/test.rb
Comment thread public/400.html
Comment thread public/406-unsupported-browser.html
Comment thread public/422.html
The Procfile is used for  local and remote deployment
Copy link
Copy Markdown
Collaborator

@compwron compwron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@compwron compwron merged commit 90679bb into rubyforgood:main May 27, 2026
13 checks passed
@stefannibrasil stefannibrasil review requested due to automatic review settings May 27, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

db Touches database schema or migrations dependencies Touches dependency files ruby Touches Ruby code 🧪 Tests Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade Rails from 7.2 to 8.x

3 participants